Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router for acre #53

Closed
wants to merge 6 commits into from
Closed

Router for acre #53

wants to merge 6 commits into from

Conversation

dimpar
Copy link
Member

@dimpar dimpar commented Nov 28, 2023

WIP

@dimpar dimpar changed the base branch from main to token-vault November 28, 2023 16:09
@dimpar dimpar mentioned this pull request Nov 30, 2023

/// @notice Acre Manager address. Only Acre Manager can set or remove
/// Strategy Allocators.
/// @notice Acre Manager address. Only Acre Manager can set or remove Vaults.
address public acreManager;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of introducing onlyAcreManager modifier in this contract, maybe we could just use the onlyOwner modifier from Ownable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a border line biz decision. I assumed we'd have at least one role like Acre Manager and having an owner for different things like contract upgrades. If we move ownership to DAO/Council and need to quickly add/remove a Yield Module then from my experience it can take a while. Acre Manager can act faster. Anyway, I'm fine with both, just need some biz decisions and implement accordingly.

/// @notice Routes funds from stBTC (Acre) to a given vault
/// @param vault Address of the vault to route the funds to.
/// @param amount Amount of TBTC to deposit.
function deposit(address vault, uint256 amount) public {
require(msg.sender == address(stBTC), "stBTC only");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of requiring stBTC contract to call deposit/redeem functions, could we introduce a maintainer/keeper role that will be allowed to call these functions?

The holder of this role will be a bot or a contract with consensus or veto mechanism.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're making an Acre contract the one that holds TBTC and TBTC yield then either way we need to call a function on Acre so it can approve the TBTC allowance that AcreRouter can proxy to a Yield Module. This makes AcreRouter asset-less, it can do some math and routes assets back and forth, but it doesn't hold actual tokens. So back to maintainer/keeper.. why don't we implement something like this:

Acre {
  (...)

  // we can call it fund/sendAssets or whatever
  routeAssets(...) onlyMaintainerOrManager {
    tBTC.approve(address(acreRouter), amount);
    AcreRouter.deposit(vault, amount);
  }
}

I bet similar case would be for Redeem/Withdraw functions, except AcreRouter will take TBTC assets from YieldModule and route it back to Acre contract. Thoughts?

Added some of the functions for Acre Router backed by OpenZeppelin
ERC4626 implementation.
Vault is a more generic name and this wording is present in ERC4626
standard.
It is required to provide expected min shares or assets. If the req is
not satisfied, the tx will be reverted.
Distribution to a Yield Module Vault is driven by distributions
percentage set during the Vault addition or update by the Acre Manager.
The concrete amount is calculated as the vault's percent allowance of
the total TBTC balance in Acre (stBTC) contract.
@dimpar
Copy link
Member Author

dimpar commented Dec 6, 2023

This PR will be split into smaller PRs: handling vault, adding deposit and redeem functions, adding vaults distribution and handling upgradability.

@dimpar dimpar closed this Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants